﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace XCT.Class
{
    class clsDBG
    {
        #region "Attributes"

        private int iD_L;
        private int maChietTinhML;
        private string soLSX;
        private string maSP;
        private string tuanKH;
        private DateTime ngayTH;
        private string maChungLoai_Mousse;
        private string maMau_Mousse;
        private int maHoaVan_Mousse;
        private int dvtID;
        private string maCD;
        private float doLy;
        private float dinhMuc;
        private string quiCach;
        private int coSoID;
        private string maMau_SP;
        private string doShore;
        private string ghiChuChiTiet;
        private float sLKH;
        private float sL_Nhap_Ca1;
        private float sL_Nhap_Ca2;
        private float sL_Nhap_Ca3;
        private float tong_SL_Nhap;
        private string ghiChu;
        private string userUpdate;
        private DateTime dateUpdate;
        #endregion

        #region "Properties"

        public int MaChietTinhML
        {
            get { return maChietTinhML; }
            set { maChietTinhML = value; }
        }

        public int ID_L
        {
            get { return iD_L; }
            set { iD_L = value; }
        }

        public string SoLSX
        {
            get { return soLSX; }
            set { soLSX = value; }
        }

        public string MaSP
        {
            get { return maSP; }
            set { maSP = value; }
        }

        public string TuanKH
        {
            get { return tuanKH; }
            set { tuanKH = value; }
        }

        public DateTime NgayTH
        {
            get { return ngayTH; }
            set { ngayTH = value; }
        }

        public string MaChungLoai_Mousse
        {
            get { return maChungLoai_Mousse; }
            set { maChungLoai_Mousse = value; }
        }

        public string MaMau_Mousse
        {
            get { return maMau_Mousse; }
            set { maMau_Mousse = value; }
        }

        public int MaHoaVan_Mousse
        {
            get { return maHoaVan_Mousse; }
            set { maHoaVan_Mousse = value; }
        }

        public int DvtID
        {
            get { return dvtID; }
            set { dvtID = value; }
        }

        public string MaCD
        {
            get { return maCD; }
            set { maCD = value; }
        }

        public float DoLy
        {
            get { return doLy; }
            set { doLy = value; }
        }

        public float DinhMuc
        {
            get { return dinhMuc; }
            set { dinhMuc = value; }
        }

        public string QuiCach
        {
            get { return quiCach; }
            set { quiCach = value; }
        }

        public int CoSoID
        {
            get { return coSoID; }
            set { coSoID = value; }
        }
        
        public string MaMau_SP
        {
            get { return maMau_SP; }
            set { maMau_SP = value; }
        }

        public string DoShore
        {
            get { return doShore; }
            set { doShore = value; }
        }

        public string GhiChuChiTiet
        {
            get { return ghiChuChiTiet; }
            set { ghiChuChiTiet = value; }
        }

        public float SLKH
        {
            get { return sLKH; }
            set { sLKH = value; }
        }

        public float SL_Nhap_Ca1
        {
            get { return sL_Nhap_Ca1; }
            set { sL_Nhap_Ca1 = value; }
        }

        public float SL_Nhap_Ca2
        {
            get { return sL_Nhap_Ca2; }
            set { sL_Nhap_Ca2 = value; }
        }

        public float SL_Nhap_Ca3
        {
            get { return sL_Nhap_Ca3; }
            set { sL_Nhap_Ca3 = value; }
        }

        public float Tong_SL_Nhap
        {
            get { return tong_SL_Nhap; }
            set { tong_SL_Nhap = value; }
        }

        public string GhiChu
        {
            get { return ghiChu; }
            set { ghiChu = value; }
        }

        public string UserUpdate
        {
            get { return userUpdate; }
            set { userUpdate = value; }
        }

        public DateTime DateUpdate
        {
            get { return dateUpdate; }
            set { dateUpdate = value; }
        }

        #endregion

        #region "Dùng chung"

        // Tim LSX
        public DataSet TimLSX(string tabName)
        {
            DataProvider dp = new DataProvider();
            DataSet ds = new DataSet();

            if (tabName == "tabDBG1")
            {
                SqlParameter[] arrPara = new SqlParameter[2];
                arrPara[0] = new SqlParameter("@pSoLSX", SqlDbType.VarChar);
                arrPara[0].Value = SoLSX;

                arrPara[1] = new SqlParameter("@pTenCD", SqlDbType.VarChar);
                arrPara[1].Value = "DBG";

                ds = dp.fdtsDocDuLieuSP("sp_TimLSX_ChietTinh", arrPara);
            }
            else if (tabName == "tabDBG2")
            {
                SqlParameter[] arrPara = new SqlParameter[1];
                arrPara[0] = new SqlParameter("@pSoLSX", SqlDbType.VarChar);
                arrPara[0].Value = SoLSX;

                ds = dp.fdtsDocDuLieuSP("sp_TimLSX_DBG", arrPara);
            }
            return ds;
        }

        #endregion

        #region "tabDBG1"

        // Đọc LSX cua điều phối theo TuanKH
        public DataSet DocLSXTheoTuanKH(string TuanKH)
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@pTuanKH", SqlDbType.VarChar);
            arrPara[0].Value = TuanKH;

            return dp.fdtsDocDuLieuSP("sp_layLSX_DBG", arrPara);
        }

        // Đọc Mau Chiet tinh theo LSX
        public DataSet DocMauChietTinhTheoLSX()
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@pSoLSX", SqlDbType.VarChar);
            arrPara[0].Value = SoLSX;

            return dp.fdtsDocDuLieuSP("sp_layMaMau_DBG", arrPara);
        }

        // Đọc Chiet tinh theo LSX
        public DataSet DocChietTinhDBGTheoLSX(string NgayTH)
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[3];
            arrPara[0] = new SqlParameter("@pSoLSX", SqlDbType.VarChar);
            arrPara[0].Value = SoLSX;
            arrPara[1] = new SqlParameter("@pNgayTH", SqlDbType.VarChar);
            arrPara[1].Value = NgayTH;
            arrPara[2] = new SqlParameter("@pMaMau_SP", SqlDbType.VarChar);
            arrPara[2].Value = MaMau_SP;

            return dp.fdtsDocDuLieuSP("sp_DocChietTinhDBGTheoLSX_MauSP", arrPara);
        }

        //Lưu DBG
        public Boolean LuuDBG()
        {
            SqlParameter[] arrPara = new SqlParameter[23];
            arrPara[0] = new SqlParameter("@pSoLSX", SqlDbType.VarChar);
            arrPara[0].Value = SoLSX;

            arrPara[1] = new SqlParameter("@pMaChietTinhML", SqlDbType.Int);
            arrPara[1].Value = MaChietTinhML;

            arrPara[2] = new SqlParameter("@pGhiChuChiTiet", SqlDbType.VarChar);
            arrPara[2].Value = GhiChuChiTiet;

            arrPara[3] = new SqlParameter("@pNgayTH", SqlDbType.DateTime);
            arrPara[3].Value = NgayTH;

            arrPara[4] = new SqlParameter("@pMaChungLoai_Mousse", SqlDbType.VarChar);
            arrPara[4].Value = MaChungLoai_Mousse;

            arrPara[5] = new SqlParameter("@pMaMau_Mousse", SqlDbType.VarChar);
            arrPara[5].Value = MaMau_Mousse;

            arrPara[6] = new SqlParameter("@pDoLy", SqlDbType.Float);
            arrPara[6].Value = DoLy;

            arrPara[7] = new SqlParameter("@pQuiCach", SqlDbType.VarChar);
            arrPara[7].Value = QuiCach;

            arrPara[8] = new SqlParameter("@pSL_Nhap_Ca1", SqlDbType.Float);
            arrPara[8].Value = SL_Nhap_Ca1;

            arrPara[9] = new SqlParameter("@pSL_Nhap_Ca2", SqlDbType.Float);
            arrPara[9].Value = SL_Nhap_Ca2;

            arrPara[10] = new SqlParameter("@pSL_Nhap_Ca3", SqlDbType.Float);
            arrPara[10].Value = SL_Nhap_Ca3;

            arrPara[11] = new SqlParameter("@pMaHoaVan_Mousse", SqlDbType.Int);
            arrPara[11].Value = MaHoaVan_Mousse;

            arrPara[12] = new SqlParameter("@pDvtID", SqlDbType.Int);
            arrPara[12].Value = DvtID;

            arrPara[13] = new SqlParameter("@pMaCD", SqlDbType.VarChar);
            arrPara[13].Value = MaCD;

            arrPara[14] = new SqlParameter("@pDinhMuc", SqlDbType.Float);
            arrPara[14].Value = DinhMuc;

            arrPara[15] = new SqlParameter("@pDoShore", SqlDbType.VarChar);
            arrPara[15].Value = DoShore;

            arrPara[16] = new SqlParameter("@pSLKH", SqlDbType.Float);
            arrPara[16].Value = SLKH;

            arrPara[17] = new SqlParameter("@pTong_SL_Nhap", SqlDbType.Float);
            arrPara[17].Value = Tong_SL_Nhap;

            arrPara[18] = new SqlParameter("@pMaMau_SP", SqlDbType.VarChar);
            arrPara[18].Value = MaMau_SP;

            arrPara[19] = new SqlParameter("@pGhiChu", SqlDbType.VarChar);
            arrPara[19].Value = GhiChu;

            arrPara[20] = new SqlParameter("@pMaSP", SqlDbType.VarChar);
            arrPara[20].Value = MaSP;

            arrPara[21] = new SqlParameter("@pCoSoID", SqlDbType.Int);
            arrPara[21].Value = CoSoID;

            arrPara[22] = new SqlParameter("@pUserUpdate", SqlDbType.VarChar);
            arrPara[22].Value = UserUpdate;

            DataProvider dp = new DataProvider();
            return dp.fBolThucThiSP("sp_LuuDBG", arrPara);
        }

        #endregion

        #region "tabDBG2"

        // Đọc LSX cua DBG theo TuanKH
        public DataSet DocLSX_DBGTheoTuanKH(string TuanKH)
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@pTuanKH", SqlDbType.VarChar);
            arrPara[0].Value = TuanKH;

            return dp.fdtsDocDuLieuSP("sp_DocLSX_DBGTheoTuanKH", arrPara);
        }

        // Đọc màu SP cua DBG theo TuanKH, SoLSX
        public DataSet DocMauSP_DBGTheoLSX()
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@pSoLSX", SqlDbType.VarChar);
            arrPara[0].Value = SoLSX;

            return dp.fdtsDocDuLieuSP("sp_DocMauSP_DBGTheoLSX", arrPara);
        }

        // Đọc DBG theo LSX
        public DataSet DocDBGTheoLSX_MauSP()
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[2];
            arrPara[0] = new SqlParameter("@pSoLSX", SqlDbType.VarChar);
            arrPara[0].Value = SoLSX;
            arrPara[1] = new SqlParameter("@pMaMau_SP", SqlDbType.VarChar);
            arrPara[1].Value = MaMau_SP;

            return dp.fdtsDocDuLieuSP("sp_DocDBGTheoLSX_MauSP", arrPara);
        }

        #endregion   
    }
}
